<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 17-4-7
 * Time: 22:23
 */

namespace backend\models;


use yii\base\Model;
use yii\data\Pagination;
use yii\db\Query;

class EveryIsOk extends Model
{

    public static $pagesize = 10;

    /**
     * 通过调用该方法设置提示信息
     * @param $status
     * @param $message
     */
    public static function setTisiInfo($status, $message){
        if($status){
            \Yii::$app->session->setFlash('success',$message.'成功!');
        }else{
            \Yii::$app->session->setFlash('success',$message.'失败!');
        }
    }

    /**
     * 返回得到的pager对象
     * @param Query $query
     * @return $pager Pagination
     */
    public static  function getPager(Query $query,$pagesize=false)
    {
        //得到总的数据的条数
        $totalCount = $query->count();
        //实例化分页工具条
        $pager = new Pagination([
            'totalCount'=>$totalCount,
            'pageSize'=>$pagesize?$pagesize:self::$pagesize,
        ]);
        return $pager;
    }

}